package edu.ccut.saturn.basevalidate.prvalidate;

import edu.ccut.saturn.component.DefaultSaturnValidate;
import edu.ccut.saturn.component.ValidateResult;

public class IsColorValidate extends DefaultSaturnValidate {

	private static final String colorRegExpr = "\\#[a-fA-F0-9]{6}";

	public void doValidate(Object value, Object[] args, ValidateResult result) {
		if (value.toString().length() != 7 || !value.toString().matches(colorRegExpr)) {
			sendError(_ERROR_, value, result);
		}
	}
}
